/**
 * Created by Laggo on 15/12/1.
 */
app.service('toolService', function () {
    //json to array
    this.jsonToArray = function (json) {
        var newArray = [];
        for (item in json) {
            newArray.push(json[item]);
        }
        return newArray;
    }

    this.objecttoParams = function (obj) {
        var p = [];
        for (var key in obj) {
            p.push(key + '=' + obj[key]);
        }
        return p.join('&');
    };

    this.inArray = function (ele, arr) {
        var isHave = false;
        for (var i = 0, len = arr.length; i < len; i++) {
            if(arr[i]['commodityId'] === ele){
                isHave = true;
            }
        }
        return isHave;
    }


});
